import sys
def rindex(box, x, a):
    i = a - 1
    while box[i] != x:
        i -= 1
    return i
def rrindex(box, x, a):
    i = rindex(box, x, a) - 1
    while box[i] == x:
        i -= 1
    return i
def closed(a, b, c):
    fight = [2]
    ans = (c - (a - b * (c + 1) + 1)) * b
    if ans <= 0:
        ans = 0
        fight += [0] * a + [2]
    else:
        for i in range(1, b + 1):
            fight += [0] * (c - ans // b) + [1] * (ans // b) + [0]
        if len(fight) > a + 1:
            fight.pop()
        fight += [2]
    return [ans, fight]
N, T, K = map(int, input().split())
[sq, field] = closed(N, T, K) 
print(sq)
ships = [T] + [None] * N
while True:
    x = int(input())
    if field[x] == 1:
        print(1)
        sys.exit()
    field[x] = 2
    i = rindex(field, 2, x) + 1
    x1 = rrindex(field, 2, x)
    x2 = x
    j = field.index(2, x2 + 1) - 1
    sq -= field[i:j + 1].count(1)
    t1 = (x1 - i + 1) // (K + 1)
    t2 = (j - x + 1) // (K + 1)
    if t1 + t2 != ships[i - 1]:
        print(0, 0)
        if x == i:
            N -= 1
            ships[]
        continue
    ships[i - 1] = t1
    ships[x] = t2
    [sq1, field1] = closed(x - i, t1, K)
    [sq2, field2] = closed(j - x, t2, K)
    sq += sq1 + sq2
    field[i - 1:x + 2] = field1
    field[x:j + 1] = field2
    print(0, sq)
    